﻿#include "stdafx.h"
#include "LetGen.h"
#include "utility.h"

llvm::Value * LetGen::generateCode(llvm::Module *m, llvm::Function *func, llvm::IRBuilder<>&builder)
{
	llvm::Value* l = left->generateCode(m, func, builder);
	assert(l->getType()->isPointerTy());

	auto valueType = l->getType()->getPointerElementType();
	auto *r=right->generateCode(m, func, builder);
	r = load(builder, r);
	r = try_cast(builder, valueType, r);
	return builder.CreateStore(r, l);
}
